import request from './request'
// 获取指定url的商品列表
// page表示页面，默认为1
export const getList = (url, page = 1) => {
  let api = ''
  const pageSize = 20 // 每页显示记录条数
  const start = (page - 1) * pageSize
  const id = url.slice(url.indexOf('=') + 1)
  if (url.startsWith('youxuan://column')) {
    api = `/api/column/${id}/items?start=${start}`
  } else {
    api = `/api/category/${id}/items?start=${start}&sort=0`
  }
  return request({
    url: api,
    method: 'get'
  }).then(res => {
    console.log('响应数据：', res)
    if (res.items) {
      return res.items.list
    }
    return res.list
  })
}
